package com.order.controller;

import com.order.dao.DeskDao;
import com.order.pojo.Desk;
import org.apache.ibatis.annotations.Insert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@Controller
@RequestMapping("desk")
public class DeskController {
    @Autowired
    DeskDao deskDao;
    /*Integer insertDesk(Desk desk);
    Boolean setFull(Integer id);
    Boolean setEmpty(Integer id);
    Integer countDesk();
    Integer countEmptyDesk();
    List<Desk> findDesks();
    List<Desk> findEmptyDesks();*/
    //添加桌子
    @RequestMapping("insert")
    @ResponseBody
    Integer insertDesk(Desk desk)
    {
        return desk.getId();
    }
    //设置桌子状态为满
    @RequestMapping("setFull")
    @ResponseBody
    Boolean setFull(Integer id)
    {
        return deskDao.setFull(id);
    }
    //设置桌子状态为空
    @RequestMapping("serEmpty")
    @ResponseBody
    Boolean setEmpty(Integer id)
    {
        return deskDao.setEmpty(id);
    }
    //查找所有桌子
    @RequestMapping("findAll")
    @ResponseBody
    List<Desk> findDesks()
    {
        return deskDao.findDesks();
    }
    //查找所有空桌子
    @RequestMapping("findEmpty")
    @ResponseBody
    List<Desk> findEmptyDesks()
    {
        return deskDao.findEmptyDesks();
    }
}
